function showBlock(id) {
    var headId=id.split('_body');
    var header=document.getElementById(headId[0]+'_header');
    if (document.getElementById(id).style.display === "none"){
	document.getElementById(id).style.display = 'block';
        header.style.borderRadius = '3px 3px 0 0';
        header.style.MozBorderRadius='3px 3px 0 0';
        header.style.WebkitBorderRadius='3px 3px 0 0';
    } else {
	document.getElementById(id).style.display = 'none';
        header.style.borderRadius='3px';
        header.style.MozBorderRadius='3px';
        header.style.WebkitBorderRadius='3px';
    }	
}

function getCookie(name) {
	var cookie = " " + document.cookie;
	var search = " " + name + "=";
	var setStr = null;
	var offset = 0;
	var end = 0;
	if (cookie.length > 0) {
		offset = cookie.indexOf(search);
		if (offset !== -1) {
			offset += search.length;
			end = cookie.indexOf(";", offset);
			if (end === -1) {
				end = cookie.length;
			}
			setStr = unescape(cookie.substring(offset, end));
		}
	}
	return(setStr);
}

function switchLang(lang) {
    var url = document.location;
    var defLang = getCookie('lang');
    if (defLang !== lang) {
        document.cookie="lang="+lang+"; path=/;";
        document.location.replace(parseUrl(url).pathname);
    } else {
        document.location.replace(parseUrl(url).pathname);
        return false;
    }  
 
}

function parseUrl(url) {
   var u = {};
    var pattern = "^(([^:/\\?#]+):)?(//(([^:/\\?#]*)(?::([^/\\?#]*))?))?([^\\?#]*)(\\?([^#]*))?(#(.*))?$";
    var rx = new RegExp(pattern); 
    var parts = rx.exec(url);

    u.href = parts[0] || "";
    u.protocol = parts[1] || "";
    u.host = parts[4] || "";
    u.hostname = parts[5] || "";
    u.port = parts[6] || "";
    u.pathname = parts[7] || "/";
    u.search = parts[8] || "";
    u.hash = parts[10] || "";

    return u;
}


